package com.bluesky.controller;

import com.bluesky.comm.Result;
import com.bluesky.comm.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
@RequestMapping("/lesson017")
public class Lesson017Controller {


    @GetMapping("/hello")
    public Result<String> hello() throws InterruptedException {
        log.info("开始执行业务");
        TimeUnit.MILLISECONDS.sleep(500);
        log.info("业务执行完毕");
        return ResultUtils.success("欢迎和路人一起学习《高并发 & 微服务 & 性能调优实战案例100讲》");
    }

    @GetMapping("/exception")
    public Result<String> exception() throws InterruptedException {
        log.info("开始执行业务");
        //这里模拟了一个错误，10/0，会报错
        System.out.println(10 / 0);
        log.info("业务执行完毕");
        return ResultUtils.success("欢迎和路人一起学习《高并发 & 微服务 & 性能调优实战案例100讲》");
    }
}
